package com.test.p24iterator.example01;

/**
 * 书架
 * @author bcc
 */
public class BookShelf implements Aggreate{

    private Book[] books;

    private int last = 0 ;

    public BookShelf(int maxsize){
        this.books = new Book[maxsize];
    }

    public Book getBookAt(int index){
        return  books[index];
    }

    public void appendBook(Book book){
        this.books[last] = book;
        last++;
    }

    public int getLength(){
        return last;
    }

    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
}
